package client.status;

import client.MapleDisease;
import constants.skills.尖兵;
import handling.Buffstat;

import java.io.Serializable;

/**
 * @author setosan
 */
public enum MonsterStatus implements Serializable, Buffstat {

    PAD(0),
    PDR(1),
    MAD(2),
    MDR(3),
    ACC(4),
    EVA(5),
    Speed(6),
    Stun(7),
    Freeze(8),
    Poison(9),
    Seal(10),
    Darkness(11),
    PowerUp(12),
    MagicUp(13),
    PGuardUp(14),
    MGuardUp(15),
    PImmune(16),
    MImmune(17),
    Web(18),
    HardSkin(19),
    Ambush(20),
    Venom(21),
    Venom_2(21),
    Blind(22),
    心灵控制(23),
    SealSkill(23),
    Dazzle(24),
    PCounter(25),
    MCounter(26),
    RiseByToss(27),
    BodyPressure(28),
    Weakness(29),
    Showdown(30),
    MagicCrash(31),
    DamagedElemAttr(32),
    AddDamParty(33),
    HitCriDamR(34),
    Fatality(35),
    Lifting(36),
    DeadlyCharge(37),
    Smite(38),
    AddDamSkil(39),
    Incizing(40),
    DodgeBodyAttack(41),
    DebuffHealing(42),
    AddDamSkill2(43),
    BodyAttack(44),
    TempMoveAbility(45),
    FixDamRBuff(46),
    NEWUNK47(47),
    ElementDarkness(48),
    AreaInstallByHit(49),
    BMageDebuff(50),
    JaguarProvoke(51),
    JaguarBleeding(52),
    DarkLightning(53),
    PinkbeanFlowerPot(54),
    BattlePvP_Helena_Mark(55),
    PsychicLock(56),
    PsychicLockCoolTime(57),
    PsychicGroundMark(58),
    PowerImmune(59),
    PsychicForce(60),
    MultiPMDR(61),
    ElementResetBySummon(62),
    BahamutLightElemAddDam(63),
    CurseMark(64),
    BossPropPlus(65),
    MultiDamSkill(66),
    RWLiftPress(67),
    RWChoppingHammer(68),
    UNK69(69),
    UNK70(70),
    Ticktock(71),
    UNK72(72),
    UNK73(73),
    UNK74(74),
    TimeBomb(77),
    Treasure(78),
    AddEffect(79),
    Invincible(80, true),
    Explosion(81),
    HangOver(82),
    UNK83(83),
    Burned(84, true),
    BalogDisable(85, true),
    ExchangeAttack(86, true),
    AddBuffStat(87, true),
    LinkTeam(88, true),
    SoulExplosion(89, true),
    SeperateSoulP(90, true),
    SeperateSoulC(91, true),
    Ember(92, true),
    TrueSight(93, true),
    Laser(94, true),
    StatResetSkill(95, true),
    NEWUNK96(96, true),
    NEWUNK97(97, true),
    NEWUNK98(98, true),
    NEWUNK99(99, true),
    NEWUNK100(100, true),
    NEWUNK101(101, true),
    NEWUNK102(102, true),
    COUNT(103, true),
    NONE(-1);

    static final long serialVersionUID = 0L;
    private final int i;
    private final int position;
    private final boolean end;
    private int value;

    MonsterStatus(int value) {
        this.i = 1 << 31 - value % 32;
        this.position = (int) Math.floor(value / 32);
        this.end = false;
        this.value = value;
    }

    MonsterStatus(int value, boolean end) {
        this.i = 1 << 31 - value % 32;
        this.position = (int) Math.floor(value / 32);
        this.end = end;
        this.value = value;
    }

    public static MonsterStatus getBySkill_Pokemon(int skill) {
        switch (skill) {
            case 120:
                return Seal;
            case 121:
                return Blind;
            case 123:
                return Stun;
            case 125:
                return Poison;
            case 126:
                return Speed;
            case 137:
                return Freeze;
        }
        return null;
    }

    public static MapleDisease getLinkedDisease(MonsterStatus stat) {
        switch (stat) {
            case Stun:
            case Web:
                return MapleDisease.昏迷;
            case Poison:
            case 心灵控制:
                return MapleDisease.中毒;
            case Seal:
            case MagicCrash:
                return MapleDisease.封印;
            case Freeze:
                return MapleDisease.FREEZE;
            case PCounter:
                return MapleDisease.黑暗;
            case Speed:
                return MapleDisease.缓慢;
        }
        return null;
    }

    public static int genericSkill(MonsterStatus stat) {
        switch (stat) {
            case Stun: {
                return 90001001;
            }
            case Speed: {
                return 90001002;
            }
            case Poison: {
                return 90001003;
            }
            case PCounter: {
                return 90001004;
            }
            case Seal: {
                return 90001005;
            }
            case Freeze: {
                return 90001006;
            }
            case MagicCrash: {
                return 1111007;
            }
            case Darkness: {
                return 4121003;
            }
            case Weakness: {
                return 22161002;
            }
            case Web: {
                return 4111003;
            }
            case Venom: {
                return 5211004;
            }
            case Venom_2: {
                return 2311005;
            }
            case Ambush: {
                return 4121004;
            }
            case Explosion: {
                return 尖兵.三角进攻;
            }
        }
        return 0;
    }

    @Override
    public int getPosition() {
        return position;
    }

    public boolean isEmpty() {
        return end;
    }

    @Override
    public int getValue() {
        return i;
    }

    public int getOrValue() {
        return value;
    }

    public Integer getOrder() {
        return position;
    }

    public MonsterStatus getMonsterStatusById(int id) {
        for (MonsterStatus monsterStatus : MonsterStatus.values()) {
            if (monsterStatus.getValue() == id) {
                return monsterStatus;
            }
        }
        return null;
    }
}
